package com.yyfax.pay.common.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 富友业务类型
 * 新增业务主键前缀，目前规定，两个字符，请注意
 * 
 * @author buyi
 * @date 2017-08-30 10:31:42
 * @since v2.0.0
 */
public enum FuiouBusiTypeEnum {
	/** 快捷充值 */
	QUICK_CHARGE("CHARGE", "CH", "01"),
	/** 网银充值 */
	EBANK_CHARGE("CHARGE", "CH", "02"),
	/** 委托充值 */
	ENTRUST_CHARGE("CHARGE", "CH", "03"),
	/** 提现 */
	WITHDRAW("", "", "04"),
	/** 委托提现 */
	ENTRUST_WITHDRAW("ENTRUST_WITHDRAW", "EW", "05"),
	/** 冻结 */
	FROZEN("FROZEN", "FN", "06"),
	/** 开户 */
	REGISTER("REGISTER", "RE", "07"),
	/** 转账预冻结 */
	TRANSFER_FROZEN("TRANSFER_FROZEN", "TF", "08"),
	/** 转账预冻结 */
	APPROPRIATE_FROZEN("APPROPRIATE_FROZEN", "AF", "09"),
	/** 冻结到冻结 */
	FROZEN_TO_FRONZEN("FROZEN_TO_FRONZEN", "FF", "10"),
	/** 解冻 */
	UNFROZEN("UNFROZEN", "UF", "11"),
	/** 法人开户 */
	ARTIFICIAL_REGISTER("ARTIFICIAL_REGISTER", "AR", "12"),

	/** 转账(商户与个人之间) */
	TRANSFER_MERCHANT_USER("TRANSFER_MERCHANT_USER", "MU", "13"),
	/** 划拨(个人与个人之间) */
	TRANSFER_USER_USER("TRANSFER_USER_USER", "UU", "14"),
	/** 余额查询 */
	BALANCE_QUERY("BALANCE_QUERY", "BQ", "15"),
	/** 更换手机 */
	CHANGE_PHONE("CHANGE_PHONE", "CP", "16"),
	/** 用户更换银行卡 */
	USER_CHANGE_CARD("USER_CHANGE_CARD", "CC", "17"),
	/** 交易查询 */
	TRADE_QUERY("TRADE_QUERY", "TQ", "18"),

	/** 充值查询 */
	CHARGE_QUERY("CHARGE_QUERY", "", "19"),
	/** 提现查询 */
	WITHDRAW_QUERY("WITHDRAW_QUERY", "", "20"),

	/** 修改提现方式 */
	MODIFY_WITHDRAW_CASH_WAY("MODIFY_WITHDRAW_CASH_WAY", "MW", "21"),

	/** 提现退票 */
	WITHDRAW_CANCEL("WITHDRAW_CANCEL", "", "22"),

	/** 转账充值 */
	TRANSFER_CHARGE("TRANSFER_CHARGE", "CH", "23"),

	/** 协议充值 */
	PROTOCOL_CHARGE("PROTOCOL_CHARGE", "CH", "24"),
	
	/** 协议签约*/
	PROTOCOL_SIGN("PROTOCOL_SIGN", "PS", "25"),

	/** 交易文件上传 */
	FILE_TRADE_UPLOAD("BATCH_UPLOAD", "BU", "50"),
	/** 交易文件上传处理结果推送 */
	FILE_TRADE_PUSH("BATCH_UPLOAD", "BU", "51"),
	/** 交易文件下载 */
	FILE_TRADE_DOWNLOAD("BATCH_DOWNLOAD", "BD", "52"),
	/** 交易回盘文件查询 */
	FILE_TRADE_QUERY("BATCH_QUERY", "BQ", "53"),

	/** 报备文件上传 */
	FILE_CHECK_UPLOAD("BATCH_UPLOAD", "BU", "60"),
	/** 报备文件上传处理结果推送 */
	FILE_CHECK_PUSH("BATCH_UPLOAD", "BU", "61"),
	/** 报备文件下载 */
	FILE_CHECK_DOWNLOAD("BATCH_DOWNLOAD", "BD", "62"),
	/** 报备回盘文件查询 */
	FILE_CHECK_QUERY("BATCH_QUERY", "BQ", "63"),

	/** 对账文件下载 */
	FILE_ACCOUNT_DOWNLOAD("BATCH_DOWNLOAD", "BD", "70"),
	/** 协议绑卡 */
	PROTOCOL_BIND_CARD("PROTOCOL_BIND","BC","71"),
	PROTOCOL_PAY("PROTOCOL_PAY","PP","72"),
	PROTOCOL_UNBIND("PROTOCOL_UNBIND","UB","73");


	/** 交易业务主键key */
	private String key;
	/** 交易业务主键前缀 */
	private String prefix;
	private String value;

	private FuiouBusiTypeEnum(String key, String prefix, String value) {
		this.key = key;
		this.value = value;
		this.prefix = prefix;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getKey() {
		return key;
	}

	public String getPrefix() {
		return prefix;
	}

	/**
	 * 判断值
	 * 
	 * @author buyi
	 * @date 2017-09-22 11:20:16
	 * @since v2.0.0
	 * @param value
	 * @return true表示相等，false表示不相等
	 */
	public boolean isValue(String value) {
		return StringUtils.equals(getValue(), value);
	}

	/**
	 * 根据值转换成响应枚举
	 * 
	 * @author buyi
	 * @date 2017-09-04 15:00:17
	 * @since v2.0.0
	 * @param value
	 * @return
	 */
	public static FuiouBusiTypeEnum parse(String value) {
		for (FuiouBusiTypeEnum fuiouBusiTypeEnum : FuiouBusiTypeEnum.values()) {
			if (StringUtils.equals(fuiouBusiTypeEnum.getValue(), value)) {
				return fuiouBusiTypeEnum;
			}
		}

		return null;
	}

}
